#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time     : 2020-12-19 14:19
# @Author   : link-yang
# @File     : 2020-12-19.48.旋转图像
# @Software : PyCharmCE
from tools.my_methods import *


class Solution:
    def rotate(self, matrix: List[List[int]]) -> None:
        """
        Do not return anything, modify matrix in-place instead.
        """
        if not matrix:
            return
        n, m = len(matrix), len(matrix[0])
        for x in range(n // 2):
            for y in range(n // 2 + m % 2):
                u = matrix[x][y]
                x1, y1 = y, n - 1 - x
                x2, y2 = n - 1 - x, n - 1 - y
                x3, y3 = n - 1 - y, x
                matrix[x][y] = matrix[x3][y3]
                matrix[x3][y3] = matrix[x2][y2]
                matrix[x2][y2] = matrix[x1][y1]
                matrix[x1][y1] = u
